﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace RelationTextBox
{
    public class RelationTextBoxColumn : DataGridViewColumn
    {
        public RelationTextBoxColumn()
            : base(new RelationTextBoxCell())
        {
            
        }
        /// <summary>
        /// Represents the implicit cell that gets cloned when adding rows to the grid.
        /// </summary>
        [
            Browsable(false),
            DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
        ]
        public override DataGridViewCell CellTemplate
        {
            get
            {
                return base.CellTemplate;
            }

            set
            {
                //Confirm the cell must be a TxtBxBtnBrwCell。 
                if (value != null && !value.GetType().IsAssignableFrom(typeof(RelationTextBoxCell)))
                {
                    throw new InvalidCastException("Must be a RelationTextBoxCell");
                }
                base.CellTemplate = value;
            }
        }
    }
}
